﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using Microsoft.SharePoint.Security;
using Microsoft.SharePoint;
using System.IO;
using System.Diagnostics;

namespace ServBus.ListForm2010.Utility
{
    /// <summary>
    /// 记录解决方案Log的公共类
    /// </summary>
    public static class WriteLog
    {
        public static void OutLog(String featureID, String fileName, ErrorType errorType, String message)
        {
            try
            {
                SPSecurity.RunWithElevatedPrivileges(() =>
                {
                    EventLog log = new EventLog();
                    log.Source = "ListBus";
                    log.WriteEntry(string.Format("FeatureID:{0}\r\nFileName:{1}\r\nErrorType:{2}\r\nMessage:{3}",
                        featureID, fileName, errorType.ToString(), message));
                    Trace.WriteLine(message);
                });
            }
            catch
            { }

        }
    }

    public enum ErrorType
    {
        ERROR_SYSTEM = 0,
        ERROR_CUSTMOER = 1,
        INFO_CUSTOMER = 2
    }
}